import React, { Component } from 'react'
import { connect } from "react-redux"
import * as action from "../action/index.js"
import { bindActionCreators } from "redux"
import { Icon } from 'react-vant';
class Pinglun extends Component {
    componentDidMount() {
        this.props.getPinglunlist()
    }
    addshoucang(id){
        this.props.addShoucang(id)
    }
    render() {
        return (
            <div>
                {
                    this.props.pinglunArr && this.props.pinglunArr.length ? this.props.pinglunArr.map((item, index) => {
                        return <div key={index}>
                            <div className="spaceTitle">
                                <img className='headImg' src={item.headImg} alt="" />
                                <b>{item.name}</b>
                                <span>{item.time}</span>
                            </div>
                            <div className="info">
                                <img className='bigImg' src={item.img} alt="" />
                                <p>{item.text}    <span><Icon name="star-o" onClick={this.addshoucang.bind(this,item.id)}/></span> <span>{item.num}</span></p>
                            </div>
                        </div>
                    }) : "暂无评论"
                }
            </div>
        )
    }
}
let mapStateToprops = (state) => {
    return {
        ...state.ShopReduer
    }
}
let mapDisPatchToProps = (dispatch) => bindActionCreators(action, dispatch)
export default connect(mapStateToprops, mapDisPatchToProps)(Pinglun)
